import requests


def userinfo(data):
    LOGIN_URL = 'https://testpassport.rabbitpre.com/api/sso/login'
    USER_URL='https://bws.test.rabbitpre.com/api/user'
    try:
        ss=requests.session()
        r = ss.post(url=LOGIN_URL, json=data)
        res = r.json()
        if r.status_code == 200 and res.get('code') == '200' :
            print('登陆成功')
            data=ss.get(USER_URL).json().get('data')
            userid=data.get('userId')
            orgId=data.get('userOrgInfo').get('orgId')
            return userid,orgId
        else:
            raise Exception(res.get('msg'))
    except Exception as e:
        print('获取信息失败:{}'.format(e))


if __name__ == '__main__':
    data = {"account": "18576626619", "password": "111111", "fromType": "pc"}
    print(userinfo(data))
